package com.k.demo.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.k.demo.entity.PointDetail;
import com.k.demo.entity.RedBag;
import com.k.demo.mapper.PointDetailMapper;
import com.k.demo.service.PointDetailService;

@Service
public class PointDetailServiceImpl implements PointDetailService{
	
	@Autowired
	private PointDetailMapper pointDetailMapper;

	public int insertPointDetail(PointDetail pointDetail) {
		return pointDetailMapper.insertPointDetail(pointDetail);
	}
	
	public List<PointDetail> getAll(int user_id){
		return pointDetailMapper.selectAll(user_id);
	}

	//传入积分明细对象进行查找
	public PageInfo<PointDetail> searchResultWithPage(int pageNum, int pageSize, PointDetail pointDetail) {
		
		PageHelper.startPage(pageNum,pageSize);
		
		return new PageInfo<PointDetail>(pointDetailMapper.selectByPonDetail(pointDetail));
	}

	@Override
	public PageInfo<PointDetail> getAlltWithPage(int pageNum, int pageSize) {
		
		PageHelper.startPage(pageNum,pageSize);
		
		return new PageInfo<PointDetail>(pointDetailMapper.getAll());
	}

	@Override
	public Double getTotalPointByDate(String date) {
		// TODO Auto-generated method stub
		return pointDetailMapper.getTotalPointByDate(date);
	}
}
